package com.xiaoyu.izf.model;

import javax.persistence.*;
import java.util.List;
import java.util.Objects;

@Entity
public class Vocation {
    private int vocationId;
    private String vocationName;
    private Integer parentId;

    private List<Vocation> children;

    @Transient
    public List<Vocation> getChildren() {
        return children;
    }
    public void setChildren(List<Vocation> children) {
        this.children = children;
    }

    @Id
    @Column(name = "vocation_id")
    public int getVocationId() {
        return vocationId;
    }

    public void setVocationId(int vocationId) {
        this.vocationId = vocationId;
    }

    @Basic
    @Column(name = "vocation_name")
    public String getVocationName() {
        return vocationName;
    }

    public void setVocationName(String vocationName) {
        this.vocationName = vocationName;
    }

    @Basic
    @Column(name = "parent_id")
    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Vocation vocation = (Vocation) o;
        return vocationId == vocation.vocationId &&
                Objects.equals(vocationName, vocation.vocationName) &&
                Objects.equals(parentId, vocation.parentId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(vocationId, vocationName, parentId);
    }

    @Override
    public String toString() {
        return "Vocation{" +
                "vocationId=" + vocationId +
                ", vocationName='" + vocationName + '\'' +
                ", parentId=" + parentId +
                '}';
    }
}
